<!-- 生产派工 -->
<template>
  <pageHeader :title="title" :breadCrumb="breadCrumb"> </pageHeader>
  <!-- [
        { key: 1, title: '未开始' },
        { key: 2, title: '执行中' },
        { key: 3, title: '已结束' }
      ] -->
  <!-- tabs 切换 -->
  <a-tabs auto-switch lazy-load v-model:active-key="status" @change="
      () => {
        tableRef.loadData();
        reset();
        picker = void 0;
      }
    ">
    <a-tab-pane :key="1" title="未开始">
      <div style="padding: 20px">
        <!-- 顶部赛选 -->
        <div class="search-mian">
          <a-space>
            <a-input-group>
              <a-select v-model="fields" :options="fieldsValue" :style="{ flex: 1 }">
              </a-select>
              <a-input @press-enter="search" :style="{ flex: 5 }" v-model="keyWord" :placeholder="`请输入${
                  fieldsValue.filter((ele) => ele.value === fields)[0]?.label
                }`" />
            </a-input-group>
            <a-input-group>
              <a-select v-model="fieldsa" :options="[
                  { value: 'keyword', label: '计划员' },
                  // { value: 'keyword', label: '生产主管' }
                ]" :style="{ flex: 1 }">
              </a-select>
              <!-- <a-input
                @press-enter="search"
                :style="{ flex: 5 }"
                v-model="keyWord"
                :placeholder="`请输入${
                  fieldsValue.filter((ele) => ele.value === fields)[0]?.label
                }`"
              /> -->
              <a-select @change="changePersonnel" :fieldNames="{ value: 'id', label: 'name' }" :style="{ flex: 5 }" v-model="value" :options="personnelData.data || []">
              </a-select>
            </a-input-group>
            <div class="search-mian-label">
              <span style="margin-right: 20px;min-width: 56px;">任务日期</span>
              <a-range-picker @change="changePicker" v-model="picker" style="width: 254px; marginbottom: 20px" />
            </div>
            <a-button @click="tableRef.loadData()" type="primary">
              <template #icon><icon-search size="18" /> </template>
              <template #default>搜索 </template>
            </a-button>
            <a-button @click="reset" type="outline">
              <template #icon> <icon-sync size="18" /> </template>
              <template #default>重置 </template>
            </a-button>
          </a-space>
          <a-space>
            <a-button status="success">
              <template #icon>
                <icon-download />
              </template>
              <template #default>导入</template>
            </a-button>
            <a-button status="warning" @click="getDemandDeriveData">
              <template #icon>
                <icon-upload />
              </template>
              <template #default>导出</template>
            </a-button>
          </a-space>
        </div>
        <!-- 表格区 -->
        <TableTurn :args="{
            rowSelection: {
              type: 'checkbox',
              showCheckedAll: true,
            },
          }" :table-data="getData" ref="tableRef">
          <a-table-column :width="80" align="center">
            <template #title> 序号 </template>
            <template #cell="{ rowIndex }">
              {{ rowIndex + 1 }}
            </template>
          </a-table-column>
          <a-table-column :width="160" align="center" title="派工编号" data-index="code">
          </a-table-column>
          <a-table-column :width="150" align="center" title="工序名称" data-index="processName">
          </a-table-column>
          <a-table-column :width="150" align="center" title="工序产出物料" data-index="outputProductName" :ellipsis="true" :tooltip="{
              position: 'top',
            }">
          </a-table-column>
          <a-table-column :width="150" align="center" title="产出数量" data-index="schedulingNumber">
          </a-table-column>
          <a-table-column :width="150" align="center" title="投入物料">
            <template #cell="{ record }">
              {{ record?.inputMaterialNames?.join(',') }}
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产批号" data-index="batchCode">
          </a-table-column>
          <a-table-column :width="150" align="center" title="紧急等级" data-index="repairerName">
            <template #cell="{ record }">
              <p :style="{
                  color: emergencyLevel.filter(
                    (ele) => ele.id === record?.emergencyLevel
                  )[0]?.color,
                }">{{
                  emergencyLevel.filter(
                    (ele) => ele.id === record?.emergencyLevel
                  )[0]?.value
                }}</p>
            </template>
          </a-table-column>
          <!-- <a-table-column
            :width="200"
            align="center"
            title="关联生产任务单"
            data-index="taskCode"
          >
            <template #cell="{ record }">
              <a-select
                @change="(e) => changeTask({ id: record.id, taskId: e as number })"
                v-if="!record.taskCode"
                allow-search
                v-model="record.taskId"
                :field-names="{ value: 'id', label: 'code' }"
                :options="record.taskList"
                :style="{ flex: 1 }"
              >
              </a-select>
              <p v-else>{{ record.taskCode }}</p>
            </template>
          </a-table-column> -->
          <a-table-column :width="150" align="center" title="关联计划单号" data-index="workShopPlanCode">
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产BOM" data-index="bomName">
          </a-table-column>
          <a-table-column :width="200" align="center" title="计划开始日期" data-index="planBeginAt">
            <template #cell="{ record }">
              {{ `${dayjs(record.planBeginAt).format('YYYY-MM-DD hh:mm:ss')}` }}
            </template>
          </a-table-column>
          <a-table-column :width="200" align="center" title="计划完工日期" data-index="planBeginAt">
            <template #cell="{ record }">
              {{ `${dayjs(record.planBeginAt).format('YYYY-MM-DD hh:mm:ss')}` }}
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="计划员" data-index="Planner">
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产主管" data-index="supervisor">
          </a-table-column>
          <a-table-column :width="200" align="center" title="作业员" data-index="executor">
            <template #cell="{ record, rowIndex }">
              <a-input v-if="!record.executor" placeholder="请选择人员" allow-clear style="cursor: pointer" v-model="record.executorName" @click="
                  () => {
                    personnelVisible = true;
                    selectData.index = rowIndex;
                    selectData.id = record.id;
                  }
                ">
                <template #suffix>
                  <icon-down />
                </template>
              </a-input>
              <p v-else>{{ record.executor }}</p>
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="资源配置" data-index="lineName">
          </a-table-column>
          <a-table-column :width="200" align="center" title="实际开始时间" data-index="actualBeginAt">
            <template #cell="{ record }">
              {{
                `${dayjs(record.actualBeginAt).format('YYYY-MM-DD hh:mm:ss')}`
              }}
            </template>
          </a-table-column>
          <a-table-column :width="200" align="center" title="实际结束时间" data-index="actualEndAt">
            <template #cell="{ record }">
              {{ `${dayjs(record.actualEndAt).format('YYYY-MM-DD hh:mm:ss')}` }}
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产时长" data-index="planTime">
          </a-table-column>
          <a-table-column align="center" :width="180" fixed="right" title="操作">
            <template #cell="{ record }">
              <div style="display: flex; justify-content: space-around">
                <a-button @click="
                    changeStatus({
                      id: record.id,
                      isReport: true,
                      data: {
                        executor: record.executor,
                        taskCode: record.taskCode,
                      },
                    })
                  " type="text" :disabled="record.isReport">
                  开始作业
                </a-button>
                <a-button type="text" :disabled="!record.isReport" @click="changeStatus({ id: record.id, isReport: false })">
                  停⽌作业
                </a-button>
              </div>
            </template>
          </a-table-column>
        </TableTurn>
      </div>
    </a-tab-pane>
    <a-tab-pane :key="2" title="执行中">
      <div style="padding: 20px">
        <div class="search-mian">
          <a-space>
            <a-input-group>
              <a-select v-model="fields" :options="fieldsValue" :style="{ flex: 1 }">
              </a-select>
              <a-input @press-enter="search" :style="{ flex: 5 }" v-model="keyWord" :placeholder="`请输入${
                  fieldsValue.filter((ele) => ele.value === fields)[0]?.label
                }`" />
            </a-input-group>
            <a-input-group>
              <a-select v-model="fieldsa" :options="[
                  { value: 'keyword', label: '计划员' },
                  // { value: 'keyword', label: '生产主管' }
                ]" :style="{ flex: 1 }">
              </a-select>
              <!-- <a-input
                @press-enter="search"
                :style="{ flex: 5 }"
                v-model="keyWord"
                :placeholder="`请输入${
                  fieldsValue.filter((ele) => ele.value === fields)[0]?.label
                }`"
              /> -->
              <a-select @change="changePersonnel" :fieldNames="{ value: 'id', label: 'name' }" :style="{ flex: 5 }" v-model="value" :options="personnelData.data || []">
              </a-select>
            </a-input-group>
            <div>
              <span style="margin-right: 20px">任务日期</span>
              <a-range-picker @change="changePicker" v-model="picker" style="width: 254px; marginbottom: 20px" />
            </div>
            <a-button @click="tableRef.loadData()" type="primary">
              <template #icon><icon-search size="18" /> </template>
              <template #default>搜索 </template>
            </a-button>
            <a-button @click="reset" type="outline">
              <template #icon> <icon-sync size="18" /> </template>
              <template #default>重置 </template>
            </a-button>
          </a-space>
          <a-space>
            <a-button status="success">
              <template #icon>
                <icon-download />
              </template>
              <template #default>导入</template>
            </a-button>
            <a-button status="warning" @click="getDemandDeriveData">
              <template #icon>
                <icon-upload />
              </template>
              <template #default>导出</template>
            </a-button>
          </a-space>
        </div>
        <TableTurn ref="tableRefTwo" :args="{
            rowSelection: {
              type: 'checkbox',
              showCheckedAll: true,
            },
          }" :table-data="getData">
          <a-table-column :width="80" align="center">
            <template #title> 序号 </template>
            <template #cell="{ rowIndex }">
              {{ rowIndex + 1 }}
            </template>
          </a-table-column>
          <a-table-column :width="160" align="center" title="派工编号" data-index="code">
          </a-table-column>
          <a-table-column :width="150" align="center" title="工序名称" data-index="processName">
          </a-table-column>
          <a-table-column :width="150" align="center" title="工序产出物料" data-index="outputProductName" :ellipsis="true" :tooltip="{
              position: 'top',
            }">
          </a-table-column>
          <a-table-column :width="150" align="center" title="产出数量" data-index="schedulingNumber">
          </a-table-column>
          <a-table-column :width="150" align="center" title="投入物料">
            <template #cell="{ record }">
              {{ record?.inputMaterialNames?.join(',') }}
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产批号" data-index="batchCode">
          </a-table-column>
          <a-table-column :width="150" align="center" title="紧急等级" data-index="repairerName">
            <template #cell="{ record }">
              <p :style="{
                  color: emergencyLevel.filter(
                    (ele) => ele.id === record?.emergencyLevel
                  )[0]?.color,
                }">{{
                  emergencyLevel.filter(
                    (ele) => ele.id === record?.emergencyLevel
                  )[0]?.value
                }}</p>
            </template>
          </a-table-column>
          <!-- <a-table-column
            :width="150"
            align="center"
            title="关联生产任务单"
            data-index="taskCode"
          >
          </a-table-column> -->
          <a-table-column :width="150" align="center" title="关联计划单号" data-index="workShopPlanCode">
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产BOM" data-index="bomName">
          </a-table-column>
          <a-table-column :width="200" align="center" title="计划开始日期" data-index="planBeginAt">
            <template #cell="{ record }">
              {{ `${dayjs(record.planBeginAt).format('YYYY-MM-DD hh:mm:ss')}` }}
            </template>
          </a-table-column>
          <a-table-column :width="200" align="center" title="计划完工日期" data-index="planBeginAt">
            <template #cell="{ record }">
              {{ `${dayjs(record.planBeginAt).format('YYYY-MM-DD hh:mm:ss')}` }}
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="计划员" data-index="Planner">
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产主管" data-index="supervisor">
          </a-table-column>
          <a-table-column :width="150" align="center" title="作业员" data-index="executor">
            <template #cell="{ record }">
              {{ record.executor }}
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="资源配置" data-index="lineName">
          </a-table-column>
          <a-table-column :width="200" align="center" title="实际开始时间" data-index="actualBeginAt">
            <template #cell="{ record }">
              {{
                `${dayjs(record.actualBeginAt).format('YYYY-MM-DD hh:mm:ss')}`
              }}
            </template>
          </a-table-column>
          <a-table-column :width="200" align="center" title="实际结束时间" data-index="actualEndAt">
            <template #cell="{ record }">
              {{ `${dayjs(record.actualEndAt).format('YYYY-MM-DD hh:mm:ss')}` }}
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产时长" data-index="planTime">
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产进度" data-index="planTime">
            <template #cell="{ record }">
              {{ record.aa }}
              <a-progress :percent="1" />
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="良品数量" data-index="planTime">
          </a-table-column>
          <a-table-column :width="150" align="center" title="不良品数量" data-index="planTime">
          </a-table-column>
          <a-table-column :width="150" align="center" title="报废数量" data-index="planTime">
          </a-table-column>
          <a-table-column :width="150" align="center" title="状态" data-index="status">
            <template #cell="{ record }">
              <div v-if="record.status === 4" class="status" :style="{
                  color: '#ffcc00',
                }">
                <p :style="{
                    'background': '#ffcc00',
                    'box-shadow': `0px 0px 5px`,
                  }"></p>
                已暂停
              </div>
              <div v-else class="status" :style="{
                  color: '#4e8bfb',
                }">
                <p :style="{
                    'background': '#4e8bfb',
                    'box-shadow': `0px 0px 5px`,
                  }"></p>
                执行中
              </div>
            </template>
          </a-table-column>
          <a-table-column align="center" :width="120" fixed="right" title="操作">
            <template #cell="{ record }">
              <div style="display: flex; justify-content: space-around">
                {{ record.status }}
                <a-button v-if="!record.isReport" type="text" @click="changeStatus({ id: record.id, isReport: true })">开始
                </a-button>
                <a-button v-else type="text" status="warning" @click="changeStatus({ id: record.id, isReport: false })">暂停
                </a-button>
              </div>
            </template>
          </a-table-column>
        </TableTurn>
      </div>
    </a-tab-pane>
    <a-tab-pane :key="3" title="已完工">
      <div style="padding: 20px">
        <div class="search-mian">
          <a-space>
            <a-input-group>
              <a-select v-model="fields" :options="fieldsValue" :style="{ flex: 1 }">
              </a-select>
              <a-input @press-enter="search" :style="{ flex: 5 }" v-model="keyWord" :placeholder="`请输入${
                  fieldsValue.filter((ele) => ele.value === fields)[0]?.label
                }`" />
            </a-input-group>
            <a-input-group>
              <a-select v-model="fieldsa" :options="[
                  { value: 'keyword', label: '计划员' },
                  // { value: 'keyword', label: '生产主管' }
                ]" :style="{ flex: 1 }">
              </a-select>
              <!-- <a-input
                @press-enter="search"
                :style="{ flex: 5 }"
                v-model="keyWord"
                :placeholder="`请输入${
                  fieldsValue.filter((ele) => ele.value === fields)[0]?.label
                }`"
              /> -->
              <a-select @change="changePersonnel" :fieldNames="{ value: 'id', label: 'name' }" :style="{ flex: 5 }" v-model="value" :options="personnelData.data || []">
              </a-select>
            </a-input-group>
            <div>
              <span style="margin-right: 20px">任务日期</span>
              <a-range-picker @change="changePicker" v-model="picker" style="width: 254px; marginbottom: 20px" />
            </div>
            <a-button @click="tableRef.loadData()" type="primary">
              <template #icon><icon-search size="18" /> </template>
              <template #default>搜索 </template>
            </a-button>
            <a-button @click="reset" type="dashed">
              <template #icon> <icon-sync size="18" /> </template>
              <template #default>重置 </template>
            </a-button>
          </a-space>

          <a-space>
            <a-button status="success">
              <template #icon>
                <icon-download />
              </template>
              <template #default>导入</template>
            </a-button>
            <a-button status="warning" @click="getDemandDeriveData">
              <template #icon>
                <icon-upload />
              </template>
              <template #default>导出</template>
            </a-button>
          </a-space>
        </div>
        <TableTurn ref="tableRefThree" :args="{
            rowSelection: {
              type: 'checkbox',
              showCheckedAll: true,
            },
          }" :table-data="getData">
          <a-table-column :width="80" align="center">
            <template #title> 序号 </template>
            <template #cell="{ rowIndex }">
              {{ rowIndex + 1 }}
            </template>
          </a-table-column>
          <a-table-column :width="160" align="center" title="派工编号" data-index="code">
          </a-table-column>
          <a-table-column :width="150" align="center" title="工序名称" data-index="processName">
          </a-table-column>
          <a-table-column :width="150" align="center" title="工序产出物料" data-index="outputProductName" :ellipsis="true" :tooltip="{
              position: 'top',
            }">
          </a-table-column>
          <a-table-column :width="150" align="center" title="产出数量" data-index="schedulingNumber">
          </a-table-column>
          <a-table-column :width="150" align="center" title="投入物料">
            <template #cell="{ record }">
              {{ record?.inputMaterialNames?.join(',') }}
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产批号" data-index="batchCode">
          </a-table-column>
          <a-table-column :width="150" align="center" title="紧急等级" data-index="repairerName">
            <template #cell="{ record }">
              <p :style="{
                  color: emergencyLevel.filter(
                    (ele) => ele.id === record?.emergencyLevel
                  )[0]?.color,
                }">{{
                  emergencyLevel.filter(
                    (ele) => ele.id === record?.emergencyLevel
                  )[0]?.value
                }}</p>
            </template>
          </a-table-column>
          <!-- <a-table-column
            :width="150"
            align="center"
            title="关联生产任务单"
            data-index="taskCode"
          >
          </a-table-column> -->
          <a-table-column :width="150" align="center" title="关联计划单号" data-index="workShopPlanCode">
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产BOM" data-index="bomName">
          </a-table-column>
          <a-table-column :width="200" align="center" title="计划开始日期" data-index="planBeginAt">
            <template #cell="{ record }">
              {{ `${dayjs(record.planBeginAt).format('YYYY-MM-DD hh:mm:ss')}` }}
            </template>
          </a-table-column>
          <a-table-column :width="200" align="center" title="计划完工日期" data-index="planBeginAt">
            <template #cell="{ record }">
              {{ `${dayjs(record.planBeginAt).format('YYYY-MM-DD hh:mm:ss')}` }}
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="计划员" data-index="Planner">
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产主管" data-index="supervisor">
          </a-table-column>
          <a-table-column :width="150" align="center" title="作业员" data-index="executor">
            <template #cell="{ record }">
              {{ record.executor }}
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="资源配置" data-index="lineName">
          </a-table-column>
          <a-table-column :width="200" align="center" title="实际开始时间" data-index="actualBeginAt">
            <template #cell="{ record }">
              {{
                `${dayjs(record.actualBeginAt).format('YYYY-MM-DD hh:mm:ss')}`
              }}
            </template>
          </a-table-column>
          <a-table-column :width="200" align="center" title="实际结束时间" data-index="actualEndAt">
            <template #cell="{ record }">
              {{ `${dayjs(record.actualEndAt).format('YYYY-MM-DD hh:mm:ss')}` }}
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产时长" data-index="planTime">
          </a-table-column>
          <a-table-column :width="150" align="center" title="生产进度" data-index="planTime">
            <template #cell="{ record }">
              {{ record.aa }}
              <a-progress :percent="1" />
            </template>
          </a-table-column>
          <a-table-column :width="150" align="center" title="良品数量" data-index="planTime">
          </a-table-column>
          <a-table-column :width="150" align="center" title="不良品数量" data-index="planTime">
          </a-table-column>
          <a-table-column :width="150" align="center" title="报废数量" data-index="planTime">
          </a-table-column>
        </TableTurn>
      </div>
    </a-tab-pane>
  </a-tabs>
  <personnelModel :title="'请选择作业人员'" @personnelId="changePersonnelId" v-model:personnelVisible="personnelVisible" />
</template>

<script lang="ts" setup>
import { GetPersonnelinformation } from '@/api/home/System settings/personal-information/index';
import {
  GetDispatching,
  GetTaskList,
  PutDispatching,
} from '@/api/produce-management/produce-list/index';
import dayjs from 'dayjs';
import { reactive, ref, onMounted } from 'vue';
import pageHeader from '@/components/page-header/index.vue';
import { useRouter } from 'vue-router';
import { Message } from '@arco-design/web-vue';

let tableRef = ref(); //未开始
const picker = ref();
let tableRefTwo = ref(); //执行中
let tableRefThree = ref(); //已完工
const value = ref();
const fields = ref('code');
const fieldsa = ref('keyword');
const personnelData = reactive({ data: [] });
const personnelVisible = ref(false);
const status = ref(1);
const selectData = reactive({
  index: 0,
  id: 0,
});
// 紧急等级
const emergencyLevel = [
  { id: 0, value: '--', color: '#000' },
  { id: 1, value: '一般', color: '#009933' },
  { id: 2, value: '紧急', color: '#409eff' },
  { id: 3, value: '加急', color: '#ff8000' },
  { id: 4, value: '特急', color: '#ff0000' },
];
const orderStatus = [
  { id: 1, value: '待确认', backgroundColor: '#cccccc' },
  { id: 2, value: '已确认', backgroundColor: '#3d92ff' },
  { id: 3, value: '待排程', backgroundColor: '#cccccc' },
  { id: 4, value: '已排程', backgroundColor: '#3d92ff' },
  { id: 5, value: '生产中', backgroundColor: '#ff8000' },
  { id: 6, value: '已完工', backgroundColor: '#2cad70' },
];
const fieldsValue = [
  { value: 'code', label: '派工编号' },
  // { value: 'keyword', label: '任务单名称' },
  // { value: 'keyword', label: '生产批次号' }
  // { value: 'customName', label: '客户名称' }
];
// 派工编号
const keyWord = ref('');
// 路由
const router = useRouter();
const title: string = '生产派工';
const breadCrumb: string[] = ['生产管理', '生产派工'];
const clientList: any = reactive({ data: [] });
// 获取表格数据
const getData = async (pageData?: any) => {
  try {
    const search: any = {};
    search[fields.value] = keyWord.value;
    if (value.value) {
      search.plannerId = value.value;
    }
    if (picker.value) {
      search.planBeginAt = +new Date(picker.value[0]);
      search.planEndAt = +new Date(picker.value[1]);
    }
    let res: any = { content: [] };

    // if (status.value === 1) {
    //   const res1 = await GetDispatching({ ...pageData, status: status.value });
    //   const res2 = await GetDispatching({ ...pageData, status: 2 });
    //   if (Array.isArray(res1.content)) {
    //     res.content = [...res1.content, ...res.content];
    //   }
    //   if (Array.isArray(res2.content)) {
    //     res.content = [...res2.content, ...res.content];
    //   }
    //   res.pageable = res1.pageable;
    //   res.totalItems = res1.totalItems + res2.totalItems;
    //   for (const ele of res.content) {
    //     if (!ele?.taskCode) {
    //       // eslint-disable-next-line no-await-in-loop
    //       const data = await GetTaskList({ id: ele.id });
    //       ele.taskList = data ? data : [];
    //     }
    //   }
    // } else if (status.value === 2) {
    //   const res1 = await GetDispatching({ ...pageData, status: 3 });
    //   const res2 = await GetDispatching({ ...pageData, status: 4 });
    //   if (Array.isArray(res1.content)) {
    //     res.content = [...res1.content, ...res.content];
    //   }
    //   if (Array.isArray(res2.content)) {
    //     res.content = [...res2.content, ...res.content];
    //   }
    //   res.pageable = res1.pageable;
    //   res.totalItems = res1.totalItems + res2.totalItems;
    // } else {
    res = await GetDispatching({
      ...pageData,
      status: status.value,
      ...search,
    });
    // for (const ele of res.content) {
    //   if (!ele?.taskCode) {
    //     // eslint-disable-next-line no-await-in-loop
    //     const data = await GetTaskList({ id: ele.id });
    //     ele.taskList = data ? data : [];
    //   }
    // }
    return Promise.resolve(res);
  } catch (error: unknown) {
    console.log(error);
  }
};
// 获取人员信息列表
const init = async () => {
  try {
    const res = await GetPersonnelinformation({
      page: 10,
      size: -1,
    });
    personnelData.data = res.content.data;
  } catch (err: unknown) {
    console.log(err);
  }
};
// 重置
const reset = () => {
  value.value = null;
  keyWord.value = '';
  picker.value = '';
  tableRef.value.loadData();
};
init();
// 计划员选择
const changePersonnel = (e: any) => {
  tableRef.value.loadData();
};
// 时间选择
const changePicker = (e) => {
  tableRef.value.loadData();
};
// 修改生产派工
const changePersonnelId = async (e: { id: number; name: string }) => {
  try {
    tableRef.value.tableList[selectData.index].executorId = e.id;
    tableRef.value.tableList[selectData.index].executorName = e.name;
    await PutDispatching({ id: selectData.id, executorId: e.id });
    tableRef.value.loadData();
  } catch (error) {
    console.log(error);
    Message.error(`${error}`);
  }
};
const changeTask = async (data: { id: number; taskId: number }) => {
  try {
    await PutDispatching(data);
    tableRef.value.loadData();
  } catch (error) {
    console.log(error);
    Message.error(`${error}`);
  }
};
//启动或者停止
const changeStatus = async (data: {
  id: number;
  isReport: boolean;
  data?: { executor: number; taskCode: number };
}) => {
  try {
    if (status.value === 1 && data.isReport) {
      if (!data.data?.executor) return Message.error('请选择关联执行人');
    }
    await PutDispatching(data);
    if (status.value === 1) {
      tableRef.value.loadData();
    } else if (status.value === 2) {
      tableRefTwo.value.loadData();
    } else {
      tableRefThree.value.loadData();
    }
  } catch (error) {
    console.log(error);
    Message.error(`${error}`);
  }
};
const jump = () => {
  router.push({ name: 'AddProductionOrder' });
};
const search = () => {
  //
};
</script>

<style scoped lang="less">
.search-mian {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  .arco-space {
    margin-bottom: 20px;
  }
  &-label {
    min-width: 300px;
    display: flex;
    align-items: center;
  }
}
.status {
  display: flex;
  align-items: center;
  justify-content: center;

  p {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 10px;
  }
}
:deep(.arco-tabs-content) {
  padding-top: 0px;
}
</style>
